package com.jcj.jcjmq.model;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.atomic.AtomicLong;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class Message<T> {
    private Long id;
    private T body;
    private Map<String, String> headers=new HashMap<>();


    static AtomicLong idgen = new AtomicLong(0);

    public static long getId() {
        return idgen.getAndIncrement();
    }

    public static Message<?> create(String body, Map<String, String> headers) {
        return new Message<>(getId(), body, headers);
    }

}
